package logic

import (
	"context"
	"house_srv/models/mysql"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUpdateLogic {
	return &UserUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserUpdateLogic) UserUpdate(in *house.UserUpdateRequest) (*house.UserUpdateResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	user.ID = uint(in.UserId)
	user.Status = in.Status
	err := user.UpdateUser(in.UserId, in.Status)
	if err != nil {
		logx.Error("修改用户审核失败")
		return nil, err
	}
	return &house.UserUpdateResponse{}, nil
}
